class OurClass { const auto_ptr<OtherObject> a; const auto_ptr<OtherObject> b; public: OurClass(const OtherObject &aRef, const OtherObject &bRef): a(new OtherObject(aRef)), b(new OtherObject(bRef)) {}; ~OurClass() {}; .... };
Example:
try { auto_ptr<LFile> sourceFile(fsSpec); sourceFile->OpenDataFork(fsCurPerm) .... } catch (ExceptionCode err) {...}
But don't ever pass-by-value. Since only one auto_ptr<> can own a pointer at any given time, assignment (inlcuding copy construction) will always pass the ownership of the pointer to the receiving object.